<template>
	<view class="recordBox" style="padding: 30rpx;">

		<view class="recordItem">
			<view class="title">就诊人</view>
			<view class="contentList">
				<view class="contentItem">
					<view class="label">姓名</view>
					<view class="value">{{user2.realName}}</view>
				</view>
				<view class="contentItem">
					<view class="label">年龄</view>
					<view class="value">{{user2.age}}</view>
				</view>
				<view class="contentItem">
					<view class="label">性别</view>
					<view class="value">{{user2.sex == 1?'男':'女'}}</view>
				</view>
				<view class="contentItem">
					<view class="label">就诊科室</view>
					<view class="value">{{data.deptName}}</view>
				</view>
			</view>
		</view>

		<view class="recordItem">
			<view class="title">病历</view>
			<view class="contentList">
				<view class="contentItem2">
					<view class="label">主诉</view>
					<view class="value">
						{{record.chiefComplaint}}
					</view>
				</view>
				<view class="contentItem2">
					<view class="label">现病史</view>
					<view class="value">{{record.presentIllness}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">既往史</view>
					<view class="value">{{record.pastHistory}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">过敏史</view>
					<view class="value">{{record.allergyHistory}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">客观记录</view>
					<view class="value">{{record.objectiveRecord}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">辅助检查</view>
					<view class="value">{{record.examination}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">诊断评估</view>
					<view class="value">{{record.diagnosis}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">治疗计划</view>
					<view class="value">{{record.treatmentPlan}}</view>
				</view>
				<view class="contentItem2">
					<view class="label">处方</view>
					<view class="value">
						<view style="padding: 20rpx;" v-for="(item,index) in record.medList2" :key="index">
							{{item.medName}}-{{item.medUsage}}-{{item.price}}元
						</view>
					</view>
				</view>
			</view>
		</view>


		<view v-if="record.userFk == user.uid && record.state==0" class="addButton" @click="subData">
			付款
		</view>

	</view>
</template>

<script>
	import appRequest from "@/common/appRequestUrl.js";
	export default {
		data() {
			return {
				showMedSel: false,
				medList: [],
				data: {},
				user2: {
					uid: 0
				},
				selMedList: [],
				record: {
					chiefComplaint: "", // 主诉
					presentIllness: "", // 现病史
					pastHistory: "", // 既往史
					allergyHistory: "", // 过敏史
					objectiveRecord: "", // 客观记录
					examination: "", // 辅助检查
					diagnosis: "", //诊断评估
					treatmentPlan: "", // 治疗计划
					preFk: "", // 处方
				},
				user: {}
			};
		},
		onLoad: function(options) {
			this.user = appRequest.getUserInfo();
			if (!this.user) {
				uni.redirectTo({
					url: "/pages/login/login"
				})
			}
			this.data = JSON.parse(options.param);
			this.getUser();
			this.getData();
		},
		methods: {
			subData() {
				let _this = this;
				uni.showModal({
					title: "支付",
					content: "请支付医疗费",
					cancelText: "微信",
					confirmText: "支付宝",
					success: function() {
						_this.$api.msg("支付成功");
						_this.record.state = 1;
						appRequest.request({
							method: "POST",
							data: _this.record,
							url: appRequest.urlMap.editNmMedicalRecord
						})

					}
				})
			},
			delMed(index) {
				this.selMedList.splice(index, 1);
			},
			selectClick(res) {
				this.selMedList.push(res);
				this.showMedSel = false;
			},
			getData() {
				let _this = this;
				appRequest.request({
					method: "POST",
					data: {
						regFk: this.data.id,
						validFlag: 1
					},
					url: appRequest.urlMap.findNmMedicalRecord,
					success: function(res) {
						if (res.data.code == 200) {
							_this.record = res.data.data;
						} else {
							_this.$api.msg(res.data.msg);
						}
					},
					fail: function(res) {
						_this.$api.msg("请求异常");
					}
				})
			},
			getUser() {
				let _this = this;
				appRequest.request({
					method: "POST",
					data: {
						uid: this.data.usrFk
					},
					url: appRequest.urlMap.findSysUser,
					success: function(res) {
						if (res.data.code == 200) {
							_this.user2 = res.data.data;
						} else {
							_this.$api.msg(res.data.msg);
						}
					},
					fail: function(res) {
						_this.$api.msg("请求异常");
					}
				})
			},
			changeReg() {
				let _this = this;
				this.data.state = 2;
				appRequest.request({
					method: "POST",
					data: this.data,
					url: appRequest.urlMap.editNmHosiptalRegister
				})
			}
		}
	}
</script>

<style lang="scss">
	.mainView {
		border-radius: 8px;
		box-shadow: 2px 2px 5px 1px lightgray;
	}

	.recordBox {
		height: 100%;
		padding: 0 40rpx;

		.recordItem {
			margin-top: 20rpx;
			background-color: #FFFFFF;

			.title {
				height: 66rpx;
				padding: 0 20rpx;
				line-height: 66rpx;
				background: #E1E1E1;
				font-size: 32rpx;
				color: #141414;
			}

			.contentList {
				display: flex;
				flex-direction: column;
				font-size: 28rpx;
				color: #6D6D6D;

				.contentItem {
					display: flex;
					align-items: center;
					justify-content: space-between;
					border-bottom: 1px dashed #C1C1C1;
					height: 66rpx;
					padding: 0 20rpx;
					line-height: 66rpx;
				}

				.contentItem2 {
					display: flex;
					align-items: center;
					justify-content: space-between;
					border-bottom: 1px dashed #C1C1C1;

					padding: 0 20rpx;

					.label {
						min-width: 200rpx;
					}
				}
			}

			.showDetail {
				color: #548AFB;
				padding: 20rpx 0;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}

	.addButton {
		width: 490rpx;
		height: 84rpx;
		margin: 100rpx auto 0;
		background: linear-gradient(90deg, #5088FD 0%, #62B9F9 100%);
		border-radius: 12rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		font-size: 40rpx;
		letter-spacing: 4rpx;
	}
</style>